import Vue from "vue"
import VueRouter from 'vue-router'


Vue.use(VueRouter)

const routes = [
    {
        path:'/',
        redirect: "/login",
    },
    {
        // 一个杠是默认路径
        path: '/Main',
        name: "Main",
        component: () => import('../../view/MyMain.vue'),
       
         children: [
            {
                path: '/home',
                name: "home",
                component: () => import('../../view/Home/index.vue')
            },
            {
                path: '/O_User',
                name: "user",
                component: () => import('../../view/User/index.vue')
            },
            {
                path:'/mall',
                name:"mall",
                component:()=>import('../../view/Mall/index.vue')
            },
           
        ]
    },
    {
        path:'/login',
        name:"login",
        component:()=>import('../../view/login/login.vue')
    }
]

const router = new VueRouter({
    routes,
    mode: 'hash',
  
})

// 捕获路由跳转错误，版本不兼容,
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

export default router

